package com.lt.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lt.crm.pojo.SysUser;
import com.lt.crm.service.SysUserService;
import com.lt.crm.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.apache.shiro.crypto.hash.Md5Hash;

//import javax.annotation.Resource;

/**
* @author Administrator
* @description 针对表【sys_user】的数据库操作Service实现
* @createDate 2024-06-18 16:58:48
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService{


    @Autowired
    SysUserMapper sysUserMapper;

    @Override
    public SysUser getUserByUsrName(String username) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("usr_name",username);
        return sysUserMapper.selectOne(queryWrapper);
    }

    @Override
    public String encryptPassword(String usrPassword) {
        Md5Hash  md5Hash = new Md5Hash(usrPassword,"czkt",2);
        return md5Hash.toString();
    }

    @Override
    public Page<SysUser> findUsers(String usrName, Integer roleId, Page<SysUser> page) {
        return sysUserMapper.selectInfo(usrName,roleId,page);
    }

    @Override
    public Page<SysUser> findUsers2(String usrName, Integer roleId, Page<SysUser> page) {
        return sysUserMapper.selectInfo2(usrName,roleId,page);
    }

    @Override
    public int updatebyusrId(Integer usrId) {
        return sysUserMapper.updatebyusrId(usrId);
    }

    @Override
    public int deletebyUsrId(Integer usrId) {
        return sysUserMapper.deletebyUsrId(usrId);
    }


}




